const path = require('path')
// 路径拼接  ../会抵消掉上一层
const pathStr = path.join('/a', '/b/c', '../', './d', 'e')
console.log(pathStr);  // \a\b\d\e
const fs = require('fs')
fs.readFile(path.join(__dirname, '/files/1.txt'), 'utf-8', (err, data) => {
    console.log(data);
})
//获取文件名 path.basename
const fileName = '/a/c/f/index.html'
let t = path.basename(fileName)
console.log(t);  //index.html
let h = path.basename(fileName, '.html')  //如果传了扩展名，就只显示文件名称
console.log(h);   // index

// 获取文件扩展名 path.extname()
let e = path.extname(fileName)
console.log(e);    //.html
